/**
 * 
 */
package com.module.osr.stormbringer.bus;

import com.dalonedrau.d20.Diceroller;
import com.dalonedrau.jogl.engine.GameApplet;
import com.module.stormbringer.globals.Globals;
import com.module.stormbringer.globals.Globals;
import com.module.stormbringer.globals.Globals;
import com.rpg.base.RPGConsts;

/**
 * @author Donald
 */
public final class SBPlayer {
	/** the singeton instance of {@link SBPlayer}. */
	private static SBPlayer	instance;
	/**
	 * Gets the one and only instance of {@link SBPlayer}.
	 * @return {@link SBPlayer}
	 */
	public static SBPlayer getInstance() {
		if (SBPlayer.instance == null) {
			SBPlayer.instance = new SBPlayer();
		}
		return SBPlayer.instance;
	}
	/** Hidden constructor. */
	private SBPlayer() {};
	public void computePlayerFullStats(final SBCharacter pc) {
		// clear all modifications
		pc.setModBodyFrame(0);
		pc.setModCharisma(0);
		pc.setModConstitution(0);
		pc.setModDexterity(0);
		pc.setModIntelligence(0);
		pc.setModLife(0);
		pc.setModMaxLife(0);
		pc.setModPower(0);
		pc.setModSize(0);
		pc.setModStrength(0);

		// IDENTIFY ALL EQUIPMENT AND APPLY MODS
		// TO DO

		// APPLY MODS FOR ALL SPELLS

		// SET FULL ATTRIBUTES
		pc.setFullBodyFrame(pc.getBaseBodyFrame() + pc.getModBodyFrame());
		pc.setFullCharisma(pc.getBaseCharisma() + pc.getModCharisma());
		pc.setFullConstitution(pc.getBaseConstitution()
				+ pc.getModConstitution());
		pc.setFullDexterity(pc.getBaseDexterity() + pc.getModDexterity());
		pc.setFullIntelligence(pc.getBaseIntelligence()
				+ pc.getModIntelligence());
		pc.setFullLife(pc.getBaseLife() + pc.getModLife());
		pc.setFullMaxLife(pc.getBaseMaxLife() + pc.getModMaxLife());
		pc.setFullPower(pc.getBasePower() + pc.getModPower());
		pc.setFullSize(pc.getBaseSize() + pc.getModSize());
		pc.setFullStrength(pc.getBaseStrength() + pc.getModStrength());

		// SET PAPER DOLL
		if (pc.getBaseSize() >= 9
				&& pc.getBaseSize() <= 12) {
			pc.setHeight(RPGConsts.HEIGHT_00AVERAGE);
		} else if (pc.getBaseSize() >= 13) {
			pc.setHeight(RPGConsts.HEIGHT_01TALL);
		}
		if (pc.getGender() == RPGConsts.GENDER_FEMALE) {
			if (pc.getBaseConstitution() == 18) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else if (pc.getBaseStrength() + pc.getBaseConstitution() >= 32) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else {
				pc.setMuscle(RPGConsts.MUSCLE_00AVERAGE);
			}
		} else {
			if (pc.getBaseStrength() == 18) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else if (pc.getBaseStrength() + pc.getBaseDexterity() >= 32) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else {
				pc.setMuscle(RPGConsts.MUSCLE_00AVERAGE);
			}
		}
		pc.notifyWatchers();
	}
	public void finalizeFreshHero() {
		
	}
	/**
	 * Gets a "fresh" hero for the character generation wizard.
	 * @return {@link SBCharacter}
	 */
	public SBCharacter getFreshHero() {
		return new SBCharacter();
	}
	public void rollFreshHero(final SBCharacter pc) {
		// roll random attributes
		int roll = Diceroller.getInstance().rollXdY(3, 6);
		pc.setBaseStrength(Diceroller.getInstance().rollXdY(3, 6));
		pc.setBaseConstitution(Diceroller.getInstance().rollXdY(3, 6));
		do {
			roll = Diceroller.getInstance().rollXdY(3, 6);
		} while (roll < 10);
		pc.setBaseSize(roll);
		pc.setBaseIntelligence(Diceroller.getInstance().rollXdY(3, 6));
		pc.setBasePower(Diceroller.getInstance().rollXdY(3, 6));
		pc.setBaseDexterity(Diceroller.getInstance().rollXdY(3, 6));
		pc.setBaseCharisma(Diceroller.getInstance().rollXdY(3, 6));
		computePlayerFullStats(pc);
	}
	/**
	 * Sets the body frame for a freshly-rolled hero.
	 * @param pc the freshly-created {@link SBCharacter}
	 * @param frame the body frame type
	 */
	private void setFrameFreshHero(final SBCharacter pc, final int frame) {
		pc.setBaseBodyFrame(frame);
		System.out.println("frame::" + frame);
		// set height
		int height = 12 * ((int) (pc.getBaseSize() + pc.getModSize()) - 1);
		int htMod = Diceroller.getInstance().rolldX(12);
		int size = (int) (pc.getBaseSize() + pc.getModSize());
		System.out.println("size::" + size);
		switch (size) {
		case 1:
		case 2:
		case 3:
			break;
		case 4:
			htMod = Diceroller.getInstance().rolldX(6);
			break;
		case 5:
		case 6:
			htMod = Diceroller.getInstance().rolldX(6) - 1;
			break;
		case 7:
			height = Diceroller.getInstance().rolldX(6) + 54;
			htMod = 0;
			break;
		default:
			height = Diceroller.getInstance().rolldX(2) + 60;
			htMod = (size - 8) * 2;
			break;
		}
		pc.setHeightInInches(height + htMod);
		// weight
		int weight = 10 * ((int) (pc.getBaseSize() + pc.getModSize()) - 1);
		int wtMod = Diceroller.getInstance().rolldX(10);
		switch (frame) {
		case Globals.BODY_FRAME_LIGHT:
			int roll = Diceroller.getInstance().rolldX(6);
			// check for weight above range
			switch (roll) {
			case 1:
			case 2:
			case 3:
				wtMod = 10;
				break;
			case 4:
			case 5:
				wtMod += 10;
				pc.setModConstitution(1);
				break;
			case 6:
				wtMod = Diceroller.getInstance().rolldX(20);
				pc.setModConstitution(2);
				pc.setModDexterity(-1);
				break;
			default:
				GameApplet.getInstance().fatalError(
						new Exception("invalid roll " + roll));
				break;
			}
			break;
		case Globals.BODY_FRAME_MEDIUM:
			weight = 15 * ((int) (pc.getBaseSize() + pc.getModSize()) - 1);
			wtMod = Diceroller.getInstance().rolldX(15);
			roll = Diceroller.getInstance().rolldX(10);
			switch (Diceroller.getInstance().rolldX(roll)) {
			case 1:
			case 2:
			case 3:
			case 4:
				// do nothing
				break;
			case 5:
			case 6:
			case 7:
				// 1-20 lbs lighter than min weight
				wtMod = -Diceroller.getInstance().rolldX(20) + 1;
				pc.setModConstitution(-1);
				pc.setModDexterity(1);
				break;
			case 8:
			case 9:
			case 10:
				// 1-20 lbs heavier than max weight
				wtMod = 15 + Diceroller.getInstance().rolldX(20);
				pc.setModConstitution(1);
				pc.setModDexterity(-1);
				break;
			default:
				GameApplet.getInstance().fatalError(
						new Exception("invalid roll " + roll));
				break;
			}
			break;
		default: // HEAVY
			weight = 20 * ((int) (pc.getBaseSize() + pc.getModSize()) - 1);
			wtMod = Diceroller.getInstance().rolldX(20);
			roll = Diceroller.getInstance().rolldX(10);
			switch (Diceroller.getInstance().rolldX(10)) {
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
				// do nothing
				break;
			case 6:
			case 7:
			case 8:
				// 1-20 lbs lighter than min weight
				wtMod = -Diceroller.getInstance().rolldX(20) + 1;
				pc.setModDexterity(1);
				break;
			case 9:
			case 10:
				// 2-40 lbs heavier than max weight
				wtMod = 20 + Diceroller.getInstance().rollXdY(2, 20);
				pc.setModConstitution(1);
				pc.setModDexterity(-2);
				break;
			default:
				GameApplet.getInstance().fatalError(
						new Exception("invalid roll " + roll));
				break;
			}
			break;
		}
		pc.setWeightInPounds(weight + wtMod);
	}
	/**
	 * Assigns a gender to a freshly-rolled hero.
	 * @param pc the {@link SBCharacter}
	 * @param gender the gender being assigned
	 */
	public void setFreshHeroGender(final SBCharacter pc, final int gender) {
		pc.setGender(gender);
		pc.notifyWatchers();
	}
	public void setFreshHeroRace(final SBCharacter pc) {
		int race = pc.getRace();
		do {
			race = Diceroller.getInstance().rolldXPlusY(20, -1);
		} while (race == pc.getRace());
		setFreshHeroRace(pc, race);
	}
	public void setFreshHeroRace(final SBCharacter pc, final int race) {
		// clear old mods
		computePlayerFullStats(pc);
		pc.setRace(race);
		System.out.println("set race " + race);
		int frame = Globals.BODY_FRAME_LIGHT;
		int roll = Diceroller.getInstance().rolldX(6);
		switch (roll) {
		case 1:
		case 2:
			frame = Globals.BODY_FRAME_LIGHT;
			break;
		case 3:
		case 4:
			frame = Globals.BODY_FRAME_MEDIUM;
			break;
		case 5:
		case 6:
			frame = Globals.BODY_FRAME_HEAVY;
			break;
		default:
			GameApplet.getInstance().fatalError(
						new Exception("invalid roll value " + roll));
			break;
		}
		switch (race) {
		case Globals.RACE_00MELNIBONE:
			// +1D10 to INT
			pc.setModIntelligence(Diceroller.getInstance().rolldX(10));
			// +2D6 to POW
			pc.setModPower(Diceroller.getInstance().rollXdY(2, 6));
			// +3 to SIZ
			pc.setModSize(3);
			// frame
			frame = Globals.BODY_FRAME_LIGHT;
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_00NORSE);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE02);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_01PAN_TANG:
			// +1D8 to INT
			pc.setModIntelligence(Diceroller.getInstance().rolldX(8));
			// +1D8 to POW
			pc.setModPower(Diceroller.getInstance().rolldX(8));
			// +1 to SIZ
			pc.setModSize(1);
			// frame
			frame = Globals.BODY_FRAME_HEAVY;
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_03AZTEC);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_02MYRRHYN:
			// +1D6 to INT
			pc.setModIntelligence(Diceroller.getInstance().rolldX(6));
			// +1D6 to POW
			pc.setModPower(Diceroller.getInstance().rolldX(6));
			// -2 to SIZ if SIZ > 9
			if (pc.getBaseSize() > 9) {
				pc.setModSize(-2);
			}
			// +1D6 to CHA (females only)
			if (pc.getGender() == Globals.GENDER_FEMALE) {
				pc.setModCharisma(Diceroller.getInstance().rolldX(6));
			}
			// frame
			frame = Globals.BODY_FRAME_LIGHT;
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_00NORSE);
			// set hair style
			if (pc.getGender() == Globals.GENDER_FEMALE) {
				pc.setHairStyle(Globals.HAIR_STYLE01);
			} else {
				pc.setHairStyle(Globals.HAIR_STYLE00);
			}
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLONDE_LT);
			break;
		case Globals.RACE_03DHARIJOR:
			// +1D4 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(4));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_02MAORI);
			// set hair style
			if (pc.getGender() == Globals.GENDER_FEMALE) {
				pc.setHairStyle(Globals.HAIR_STYLE01);
			} else {
				pc.setHairStyle(Globals.HAIR_STYLE00);
			}
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BRUNETTE);
			break;
		case Globals.RACE_04JHARKOR:
			// -1D4 to CHA
			pc.setModDexterity(-Diceroller.getInstance().rolldX(4));
			// +1D4 to DEX
			pc.setModDexterity(Diceroller.getInstance().rolldX(4));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_02MAORI);
			// set hair style
			if (pc.getGender() == Globals.GENDER_FEMALE) {
				pc.setHairStyle(Globals.HAIR_STYLE01);
			} else {
				pc.setHairStyle(Globals.HAIR_STYLE00);
			}
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BRUNETTE);
			break;
		case Globals.RACE_05SHAZAAR:
			// +1D6 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(6));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_02MAORI);
			// set hair style
			if (pc.getGender() == Globals.GENDER_FEMALE) {
				pc.setHairStyle(Globals.HAIR_STYLE01);
			} else {
				pc.setHairStyle(Globals.HAIR_STYLE00);
			}
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_06TARKESH:
			// frame
			if (Diceroller.getInstance().rolldX(6) <= 3) {
				frame = Globals.BODY_FRAME_MEDIUM;
			} else {
				frame = Globals.BODY_FRAME_HEAVY;
			}
			// +1D4 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(4));
			// -1 to SIZ if SIZ > 9
			if (pc.getBaseSize() > 9) {
				pc.setModSize(-1);
			}
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_03AZTEC);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_07VILMIR:
			// frame
			switch (Diceroller.getInstance().rolldX(6)) {
			case 1:
				frame = Globals.BODY_FRAME_LIGHT;
				break;
			case 2:
			case 3:
			case 4:
			case 5:
				frame = Globals.BODY_FRAME_MEDIUM;
				break;
				default:
					frame = Globals.BODY_FRAME_HEAVY;
					break;
			}
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_RED);
			break;
		case Globals.RACE_08ILMIORA:
			// frame
			switch (Diceroller.getInstance().rolldX(6)) {
			case 1:
				frame = Globals.BODY_FRAME_LIGHT;
				break;
			case 2:
			case 3:
			case 4:
			case 5:
				frame = Globals.BODY_FRAME_MEDIUM;
				break;
				default:
					frame = Globals.BODY_FRAME_HEAVY;
					break;
			}
			// +1D4 to CHA
			pc.setModCharisma(Diceroller.getInstance().rolldX(4));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE02);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLONDE_GOLD);
			break;
		case Globals.RACE_09NADSOKOR:
			// -1D6 to CON
			pc.setModConstitution(-Diceroller.getInstance().rolldX(6));
			// -1D6 to CHA
			pc.setModCharisma(-Diceroller.getInstance().rolldX(6));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_GREY);
			break;
		case Globals.RACE_10WEEPING_WASTE:
			// frame
			frame = Globals.BODY_FRAME_MEDIUM;
			// +1D6 to STR
			pc.setModStrength(Diceroller.getInstance().rolldX(6));
			// +1D6 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(6));
			// -1 to SIZ if SIZ > 9
			if (pc.getBaseSize() > 9) {
				pc.setModSize(-1);
			}
			// +1D4 to DEX
			pc.setModDexterity(Diceroller.getInstance().rolldX(4));
			// -1D6 to CHA
			pc.setModCharisma(-Diceroller.getInstance().rolldX(6));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_04ZULU);
			// set hair style
			if (pc.getGender() == Globals.GENDER_FEMALE) {
				pc.setHairStyle(Globals.HAIR_STYLE01);
			} else {
				pc.setHairStyle(Globals.HAIR_STYLE00);
			}
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_11ELWHER:
			// frame
			frame = Globals.BODY_FRAME_MEDIUM;	
			// -2 to SIZ if SIZ > 9
			if (pc.getBaseSize() > 9) {
				pc.setModSize(-2);
			}
			// +1D4 to INT
			pc.setModIntelligence(Diceroller.getInstance().rolldX(4));
			// +1D6 to POW
			pc.setModPower(Diceroller.getInstance().rolldX(6));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_12ISLAND_PURPLE:
			// frame
			if (Diceroller.getInstance().rolldX(6) <= 3) {
				frame = Globals.BODY_FRAME_MEDIUM;
			} else {
				frame = Globals.BODY_FRAME_HEAVY;
			}
			// +1D4 to STR
			pc.setModStrength(Diceroller.getInstance().rolldX(4));
			// +1D6 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(6));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_13ARGIMILIAR:
			// frame
			frame = Globals.BODY_FRAME_MEDIUM;
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BRUNETTE);
			break;
		case Globals.RACE_14PIKARAYD:
			// frame
			if (Diceroller.getInstance().rolldX(6) <= 3) {
				frame = Globals.BODY_FRAME_MEDIUM;
			} else {
				frame = Globals.BODY_FRAME_HEAVY;
			}
			// +2D4 to STR
			pc.setModStrength(Diceroller.getInstance().rollXdY(2, 4));
			// +1 to SIZ
			pc.setModSize(1);
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_RED);
			break;
		case Globals.RACE_15LORMYR:
			// frame
			if (Diceroller.getInstance().rolldX(6) <= 3) {
				frame = Globals.BODY_FRAME_MEDIUM;
			} else {
				frame = Globals.BODY_FRAME_HEAVY;
			}
			// +2 to SIZ
			pc.setModSize(2);
			// -1D4 to INT
			pc.setModIntelligence(-Diceroller.getInstance().rolldX(4));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_00NORSE);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE02);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLONDE_GOLD);
			break;
		case Globals.RACE_16FILKHAR:
			// frame
			if (Diceroller.getInstance().rolldX(6) <= 3) {
				frame = Globals.BODY_FRAME_MEDIUM;
			} else {
				frame = Globals.BODY_FRAME_LIGHT;
			}
			// +1D4 to DEX
			pc.setModDexterity(Diceroller.getInstance().rolldX(4));
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_00NORSE);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLONDE_LT);
			break;
		case Globals.RACE_17OIN:
			// frame
			frame = Globals.BODY_FRAME_HEAVY;
			// +1D6 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(6));
			// -1D6 to INT if INT > 9
			if (pc.getBaseIntelligence() > 9) {
				pc.setModIntelligence(-Diceroller.getInstance().rolldX(6));
			}
			// -1D6 to POW if POW > 9
			if (pc.getBasePower() > 9) {
				pc.setModPower(-Diceroller.getInstance().rolldX(6));
			}
			// -1D6 to DEX if DEX > 9
			if (pc.getBaseDexterity() > 9) {
				pc.setModDexterity(-Diceroller.getInstance().rolldX(6));
			}
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLONDE_LT);
			break;
		case Globals.RACE_18YU:
			// frame
			frame = Globals.BODY_FRAME_HEAVY;
			// +1D6 to STR
			pc.setModStrength(Diceroller.getInstance().rolldX(6));
			// -1D6 to INT if INT > 9
			if (pc.getBaseIntelligence() > 9) {
				pc.setModIntelligence(-Diceroller.getInstance().rolldX(6));
			}
			// -1D6 to POW if POW > 9
			if (pc.getBasePower() > 9) {
				pc.setModPower(-Diceroller.getInstance().rolldX(6));
			}
			// -1D6 to CHA if CHA > 9
			if (pc.getBaseCharisma() > 9) {
				pc.setModCharisma(-Diceroller.getInstance().rolldX(6));
			}
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_01CELT);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE02);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		case Globals.RACE_19ORG:
			// frame
			frame = Globals.BODY_FRAME_HEAVY;
			// +1D4 to STR
			pc.setModStrength(Diceroller.getInstance().rolldX(4));
			// +1D8 to CON
			pc.setModConstitution(Diceroller.getInstance().rolldX(8));	
			// -2 to SIZ if SIZ > 9
			if (pc.getBaseSize() > 9) {
				pc.setModSize(-2);
			}
			// -1D6 to INT if INT > 9
			if (pc.getBaseIntelligence() > 9) {
				pc.setModIntelligence(-Diceroller.getInstance().rolldX(6));
			}
			// -2D4 to POW if POW > 9
			if (pc.getBasePower() > 9) {
				pc.setModPower(-Diceroller.getInstance().rollXdY(2, 4));
			}
			// -1D6 to DEX if DEX > 9
			if (pc.getBaseDexterity() > 9) {
				pc.setModDexterity(-Diceroller.getInstance().rolldX(6));
			}
			// -2D4 to CHA if CHA > 9
			if (pc.getBaseCharisma() > 9) {
				pc.setModCharisma(-Diceroller.getInstance().rollXdY(2, 4));
			}
			// set skin tone
			pc.setSkinTone(RPGConsts.SKIN_03AZTEC);
			// set hair style
			pc.setHairStyle(Globals.HAIR_STYLE01);
			// set hair color
			pc.setHairColor(Globals.HAIR_COLOR_BLACK);
			break;
		default:
			GameApplet.getInstance().fatalError(
						new Exception("invalid race value " + race));
			break;
		}
		setFrameFreshHero(pc, frame);
		// SET FULL ATTRIBUTES
		pc.setFullBodyFrame(pc.getBaseBodyFrame() + pc.getModBodyFrame());
		pc.setFullCharisma(pc.getBaseCharisma() + pc.getModCharisma());
		pc.setFullConstitution(pc.getBaseConstitution()
				+ pc.getModConstitution());
		pc.setFullDexterity(pc.getBaseDexterity() + pc.getModDexterity());
		pc.setFullIntelligence(pc.getBaseIntelligence()
				+ pc.getModIntelligence());
		pc.setFullLife(pc.getBaseLife() + pc.getModLife());
		pc.setFullMaxLife(pc.getBaseMaxLife() + pc.getModMaxLife());
		pc.setFullPower(pc.getBasePower() + pc.getModPower());
		pc.setFullSize(pc.getBaseSize() + pc.getModSize());
		pc.setFullStrength(pc.getBaseStrength() + pc.getModStrength());
		// SET PAPER DOLL
		if (pc.getFullSize() >= 9
				&& pc.getFullSize() <= 12) {
			pc.setHeight(RPGConsts.HEIGHT_00AVERAGE);
		} else if (pc.getFullSize() >= 13) {
			pc.setHeight(RPGConsts.HEIGHT_01TALL);
		}
		if (pc.getGender() == RPGConsts.GENDER_FEMALE) {
			if (pc.getFullConstitution() == 18) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else if (pc.getFullStrength() + pc.getFullConstitution() >= 32
					|| pc.getFullDexterity() + pc.getFullConstitution() >= 32) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else {
				pc.setMuscle(RPGConsts.MUSCLE_00AVERAGE);
			}
		} else {
			if (pc.getFullStrength() == 18) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else if (pc.getFullStrength() + pc.getFullDexterity() >= 32
					|| pc.getFullStrength() + pc.getFullConstitution() >= 32) {
				pc.setMuscle(RPGConsts.MUSCLE_01MUSCULAR);
			} else {
				pc.setMuscle(RPGConsts.MUSCLE_00AVERAGE);
			}
		}
		pc.notifyWatchers();
	}
}
